﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using WebComponents.Data;
using WebComponents;
using SiteUtils;

public partial class Portfolio : System.Web.UI.Page {
  protected void Page_Load(object sender, EventArgs e) {
    var list = ArticleController.GetByCateID(76, Global.CurrentCultureCode).Where(a => a.IsApproved == true).ToList();
    if (list.Count > 0) {
      CollectionPager pagerNews = new CollectionPager();
      pagerNews.MaxPages = 100;
      pagerNews.PageSize = Global.PageSize("PortfolioPageSize");
      pagerNews.DataSource = list;
      int page = ConvertType.ToInt(Request.Params["p"]);
      if (page > 0)
        page -= 1;
      pagerNews.DataSourcePaged.CurrentPageIndex = page;
      pagerNews.BindToControl = rptArticle;
      rptArticle.DataSource = pagerNews.DataSourcePaged;
      rptArticle.DataBind();
      if (pagerNews.PageCount > 1) {
        lblPager.Text = "";
        lblPager.Text += string.Format("<a href=\"{1}danh-muc-dau-tu/p-{0}.gbit\" class='linkpage'><<</a>", 1, Page.ResolveClientUrl("~/"));
        for (int i = 0; i < pagerNews.PageCount; i++) {
          if (i == page)
            lblPager.Text += string.Format("<a href=\"{1}danh-muc-dau-tu/p-{0}.gbit\" class='linkpage acitve'>{0}</a>", i + 1, Page.ResolveClientUrl("~/"));
          else
            lblPager.Text += string.Format("<a href=\"{1}danh-muc-dau-tu/p-{0}.gbit\" class='linkpage'>{0}</a>", i + 1, Page.ResolveClientUrl("~/"));
        }
        lblPager.Text += string.Format("<a href=\"{1}danh-muc-dau-tu/p-{0}.gbit\" class='linkpage'>>></a>", pagerNews.PageCount, Page.ResolveClientUrl("~/"));
      } else
        lblPager.Visible = false;
    }
    Page.Title = "Nhan Publicite - " + WebComponents.ResourceValueController.GetString("Site_Portfolio");
  }
  int index = 0;
  protected void rptArticle_ItemDataBound(object sender, RepeaterItemEventArgs e) {
    ArticleInfo a = e.Item.DataItem as ArticleInfo;
    if (a != null) {
      HtmlGenericControl c = e.Item.FindControl("divClass") as HtmlGenericControl;
      if (index > 0)
        c.Attributes["class"] = "project space_col_protfolio";
      index++;
      if (index > 2)
        index = 0;
    }
  }
}
